package ch.rheintalconnection.sysventory.businessServices;

import java.net.UnknownHostException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

import ch.rheintalconnection.sysventory.domain.Scan;
import ch.rheintalconnection.sysventory.domain.ScanEntry;
import ch.rheintalconnection.sysventory.domain.User;
import ch.rheintalconnection.sysventory.technicalServices.IHostScanner;
import ch.rheintalconnection.sysventory.technicalServices.IIpScanner;

public class NetworkScanner {
	
	private IIpScanner ipScanner;
	
	

	public NetworkScanner(IIpScanner ipScanner) {
		super();
		this.ipScanner = ipScanner;
	}



	public Scan scan() {
		
		List<ScanEntry> scanEntrys = new ArrayList<ScanEntry>();
		
		List<IHostScanner> hostScanners = ipScanner.scanIps();
		
		for (IHostScanner hostScanner : hostScanners) {
			
			DomainHostScanner domainHostScanner = new DomainHostScanner(hostScanner);
			try {
				ScanEntry scanEntry = domainHostScanner.scan();
				scanEntrys.add(scanEntry);
			} catch (UnknownHostException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		
		return new Scan(new Timestamp(0), new Timestamp(0), new User(), scanEntrys);
	}

}
